<template>
	<scroll-view class="page-follow-up" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="scrolltolower">
		<view class="section-list" v-if="dataList?.length">
			<view class="list-content">
				<view class="list-item" @click="toDetail(item)" v-for="item in dataList">
					<image class="list-img" :src="item.coverpic" />
					<view>
						<view class="list-name text-ellipsis">{{ item.title }}</view>
						<view class="list-disc">
							<template>
								<view class="l-1">{{ item.isfinish ? '完结' : '连载中' }}</view>
								<view class="l-2"></view>
								<view class="l-3">共{{ item.allchapter }}话</view>
							</template>
							<!-- <template>
								<view>连载</view>
								<view></view>
								<view>已更7话</view>
							</template> -->
						</view>
					</view>
					<view class="go-read">
						<image class="read-img" :src="`${imgBaseUrl}read-icon-fast.webp`" />
						<view class="read-text">速看</view>
					</view>
				</view>
			</view>
		</view>
	</scroll-view>
</template>

<script setup lang="ts">
import { getMoreList, getHistoryChaps } from '@/api'
import { onLoad } from '@dcloudio/uni-app'
import { ref } from 'vue'
const page = ref(1)
const dataList = ref<API.BookItem[]>()
let type = 0

uni.setNavigationBarTitle({ title: '更多' });

const getList = async () => {
	uni.showLoading({ title: ' ', icon: 'none' });
	const res = await getMoreList({ page_size: 20, page: 1, view_page_position: type.toString() });
	dataList.value = [...dataList.value || [], ...res.data.data];
	uni.hideLoading();
}

const toDetail = async (item: API.BookItem) => {
	// uni.navigateTo({ url: `/pages/book-detail/index?&id=${item.id}` });
	const { data } = await getHistoryChaps(item.id)
	uni.navigateTo({ url: `/pages/readingPage/index?&id=${item?.id}&chapter=${data.history_chapter}` });
}
const scrolltolower = () => {
	page.value++;
	getList();
}

onLoad((option) => {
	type = option?.type
	getList()
})
</script>

<style lang="less" scoped>
.page-follow-up {
	height: 100vh;
	width: 100vw;
	box-sizing: border-box;
	padding-bottom: 40rpx;

	.section-list {
		padding: 0 24rpx 0;

		.list-content {

			.list-item {
				margin-top: 32rpx;
				display: flex;
				flex-flow: row nowrap;
				justify-content: flex-start;
				align-items: flex-start;

				.list-img {
					width: 188rpx;
					height: 252rpx;
					border-radius: 12rpx;
					margin-right: 32rpx;
				}

				.list-name {
					width: 350rpx;
					margin-top: 40rpx;
					margin-right: 40rpx;
					font-size: 32rpx;
					color: #333333;
				}

				.list-disc {
					display: flex;
					width: 100%;
					margin-top: 16rpx;
					font-size: 24rpx;
					color: #8B8B8B;
					justify-content: flex-start;
					align-items: center;

					.l-2 {
						width: 2rpx;
						height: 16rpx;
						background-color: #DFDFDF;
						margin: 0 12rpx;
					}
				}

				.go-read {
					margin-top: 40rpx;

					.read-img {
						width: 64rpx;
						height: 64rpx;
					}

					.read-text {
						font-size: 24rpx;
						color: #0DA0FF;
						text-align: center;
					}
				}
			}
		}

	}

}
</style>